#coding=utf-8

import io
import os
import sys
import json
import fileinput

from .spine_utils import *

from clitool.core.base.BaseObject import BaseObject

class PngInfo(BaseObject):
    _name = ''
    _rotate = False
    _xy = []
    _size = []
    _orig = []
    _offset = []
    _index = 0

    def __init__(self):
        super(PngInfo, self).__init__(None)

    @property
    def name(self):
        return self._name
    @name.setter
    def name(self, value):
        self._name = value

    @property
    def rotate(self):
        return self._rotate
    @rotate.setter
    def rotate(self, value):
        self._rotate = value

    @property
    def xy(self):
        return self._xy
    @xy.setter
    def xy(self, value):
        self._xy = value

    @property
    def size(self):
        return self._size
    @size.setter
    def size(self, value):
        self._size = value

    @property
    def orig(self):
        return self._orig
    @orig.setter
    def orig(self, value):
        self._orig = value

    @property
    def offset(self):
        return self._offset
    @offset.setter
    def offset(self, value):
        self._offset = value

    @property
    def index(self):
        return self._index
    @index.setter
    def index(self, value):
        self._index = value


    def getRegion(self):
        w = 0
        h = 0
        x = self._xy[0]
        y = self._xy[1]

        if self._rotate == True:
            w = self._size[1]
            h = self._size[0]
        else:
            w = self._size[0]
            h = self._size[1]


        region = (x, y, x + w, y + h)

        return region
